import React, { Component, ReactNode, lazy } from 'react';
import { UserOutlined, LaptopOutlined, NotificationOutlined ,DashboardOutlined } from '@ant-design/icons';

const Login = lazy(() => import('../pages/Login'))
const Page404 = lazy(() => import('../pages/Page404'))
const Dashboard = lazy(() => import('../pages/index/Dashboard'))
const UserList = lazy(() => import('../pages/user/UserList'))
const AdminList = lazy(()=>import('../pages/admin/AdminList'))
const RoleList = lazy(()=>import('../pages/role/RoleList'))



export interface IRouter {
    title: string
    path: string
    key: string
    exact?: boolean
    component?: ReactNode
    icon?: ReactNode
    children?: IRouter[]
}

export const leftRouter: IRouter[] = [
    {
        title: '仪表盘',
        path: '/admin/index',
        key: 'dashboard',
        exact: true,
        icon:<DashboardOutlined/>,
        component: <Dashboard />
    },
    {
        title: '用户管理',
        path: '/admin/user',
        key: 'user',
        icon:<UserOutlined/>,
        children:[
            {
                title: '用户列表',
                path: '/admin/user/UserList',
                key: 'UserList',
                exact: true,
                icon:<UserOutlined/>,
                component: <UserList />,
            }
        ]
    },
    {
        title: '管理员管理',
        path: '/admin/admin',
        key: 'admin',
        icon:<UserOutlined/>,
        children:[
            {
                title: '管理员列表',
                path: '/admin/admin/list',
                key: 'adminList',
                exact: true,
                icon:<UserOutlined/>,
                component: <AdminList />,
            }
        ]
    },
    {
        title: '角色管理',
        path: '/admin/role',
        key: 'role',
        icon:<UserOutlined/>,
        children:[
            {
                title: '角色列表',
                path: '/admin/role/list',
                key: 'roleList',
                exact: true,
                icon:<UserOutlined/>,
                component: <RoleList />,
            }
        ]
    },

]

const topRouter:IRouter[] = []
const router:IRouter[] = [
    ...leftRouter,
    ...topRouter
]

export const unAuthRouter: IRouter[] = [
    {
        title: '登录',
        path: '/login',
        key: 'login',
        component: <Login />
    }, {
        title: '404',
        path: '*',
        key: '404',
        exact: false,
        component: <Page404 />
    }

]

export default router